unit ELE_BUDGET_GROUPID;


interface
uses
  Classes,SysUtils,DB,Uni,UniEngine;

type
  TELEBUDGETGROUPID=class(TUniEngine)
  private
    FSETYEAR  : Extended;   
    FCHRID    : string;
    FCHRCODE  : string;
    FDISPCODE : string;
    FCHRNAME  : string;
    FLEVELNUM : Extended;
    FISLEAF   : Extended;
    FENABLED  : Extended;
    FCREATEDATE: string;
    FCREATEUSER: string;
    FLATESTOPDATE: string;
    FISDELETED: Extended;
    FLATESTOPUSER: string;
    FLASTVER  : string;
    FCHRCODE1 : string;
    FCHRCODE2 : string;
    FCHRCODE3 : string;
    FCHRCODE4 : string;
    FCHRCODE5 : string;
    FRGCODE   : string;
    FPARENTID : string;
    FCHRID1   : string;
    FCHRID2   : string;
    FCHRID3   : string;
    FCHRID4   : string;
    FCHRID5   : string;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property SETYEAR  : Extended read FSETYEAR   write FSETYEAR;
    property CHRID    : string read FCHRID     write FCHRID;
    property CHRCODE  : string read FCHRCODE   write FCHRCODE;
    property DISPCODE : string read FDISPCODE  write FDISPCODE;
    property CHRNAME  : string read FCHRNAME   write FCHRNAME;
    property LEVELNUM : Extended read FLEVELNUM  write FLEVELNUM;
    property ISLEAF   : Extended read FISLEAF    write FISLEAF;
    property ENABLED  : Extended read FENABLED   write FENABLED;
    property CREATEDATE: string read FCREATEDATE write FCREATEDATE;
    property CREATEUSER: string read FCREATEUSER write FCREATEUSER;
    property LATESTOPDATE: string read FLATESTOPDATE write FLATESTOPDATE;
    property ISDELETED: Extended read FISDELETED write FISDELETED;
    property LATESTOPUSER: string read FLATESTOPUSER write FLATESTOPUSER;
    property LASTVER  : string read FLASTVER   write FLASTVER;
    property CHRCODE1 : string read FCHRCODE1  write FCHRCODE1;
    property CHRCODE2 : string read FCHRCODE2  write FCHRCODE2;
    property CHRCODE3 : string read FCHRCODE3  write FCHRCODE3;
    property CHRCODE4 : string read FCHRCODE4  write FCHRCODE4;
    property CHRCODE5 : string read FCHRCODE5  write FCHRCODE5;
    property RGCODE   : string read FRGCODE    write FRGCODE;
    property PARENTID : string read FPARENTID  write FPARENTID;
    property CHRID1   : string read FCHRID1    write FCHRID1;
    property CHRID2   : string read FCHRID2    write FCHRID2;
    property CHRID3   : string read FCHRID3    write FCHRID3;
    property CHRID4   : string read FCHRID4    write FCHRID4;
    property CHRID5   : string read FCHRID5    write FCHRID5;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AELEBUDGETGROUPID:TELEBUDGETGROUPID):TELEBUDGETGROUPID;overload;        
    class procedure CopyIt(AELEBUDGETGROUPID:TELEBUDGETGROUPID;var Result:TELEBUDGETGROUPID);overload;       
  end;

implementation

{ TELEBUDGETGROUPID }
procedure TELEBUDGETGROUPID.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('SET_YEAR').Value := SETYEAR;
        ParamByName('CHR_ID').Value := CHRID;
        ParamByName('CHR_CODE').Value := CHRCODE;
        ParamByName('DISP_CODE').Value := DISPCODE;
        ParamByName('CHR_NAME').Value := CHRNAME;
        ParamByName('LEVEL_NUM').Value := LEVELNUM;
        ParamByName('IS_LEAF').Value := ISLEAF;
        ParamByName('ENABLED').Value := ENABLED;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('CREATE_USER').Value := CREATEUSER;
        ParamByName('LATEST_OP_DATE').Value := LATESTOPDATE;
        ParamByName('IS_DELETED').Value := ISDELETED;
        ParamByName('LATEST_OP_USER').Value := LATESTOPUSER;
        ParamByName('LAST_VER').Value := LASTVER;
        ParamByName('CHR_CODE1').Value := CHRCODE1;
        ParamByName('CHR_CODE2').Value := CHRCODE2;
        ParamByName('CHR_CODE3').Value := CHRCODE3;
        ParamByName('CHR_CODE4').Value := CHRCODE4;
        ParamByName('CHR_CODE5').Value := CHRCODE5;
        ParamByName('RG_CODE').Value := RGCODE;
        ParamByName('PARENT_ID').Value := PARENTID;
        ParamByName('CHR_ID1').Value := CHRID1;
        ParamByName('CHR_ID2').Value := CHRID2;
        ParamByName('CHR_ID3').Value := CHRID3;
        ParamByName('CHR_ID4').Value := CHRID4;
        ParamByName('CHR_ID5').Value := CHRID5; 
      end;
      otEdit:
      begin
        ParamByName('SET_YEAR').Value := SETYEAR;
        ParamByName('CHR_ID').Value := CHRID;
        ParamByName('CHR_CODE').Value := CHRCODE;
        ParamByName('DISP_CODE').Value := DISPCODE;
        ParamByName('CHR_NAME').Value := CHRNAME;
        ParamByName('LEVEL_NUM').Value := LEVELNUM;
        ParamByName('IS_LEAF').Value := ISLEAF;
        ParamByName('ENABLED').Value := ENABLED;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('CREATE_USER').Value := CREATEUSER;
        ParamByName('LATEST_OP_DATE').Value := LATESTOPDATE;
        ParamByName('IS_DELETED').Value := ISDELETED;
        ParamByName('LATEST_OP_USER').Value := LATESTOPUSER;
        ParamByName('LAST_VER').Value := LASTVER;
        ParamByName('CHR_CODE1').Value := CHRCODE1;
        ParamByName('CHR_CODE2').Value := CHRCODE2;
        ParamByName('CHR_CODE3').Value := CHRCODE3;
        ParamByName('CHR_CODE4').Value := CHRCODE4;
        ParamByName('CHR_CODE5').Value := CHRCODE5;
        ParamByName('RG_CODE').Value := RGCODE;
        ParamByName('PARENT_ID').Value := PARENTID;
        ParamByName('CHR_ID1').Value := CHRID1;
        ParamByName('CHR_ID2').Value := CHRID2;
        ParamByName('CHR_ID3').Value := CHRID3;
        ParamByName('CHR_ID4').Value := CHRID4;
        ParamByName('CHR_ID5').Value := CHRID5; 
      end;  
      otDelt:
      begin
        ParamByName('CHR_ID').Value := CHRID;
 
      end;  
    end;
  end;
end;

function TELEBUDGETGROUPID.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('ELE_BUDGET_GROUPID',['CHR_ID',CHRID],AUniConnection);
end;

function TELEBUDGETGROUPID.GetNextIdex: Integer;
begin

end;

function TELEBUDGETGROUPID.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TELEBUDGETGROUPID.GetStrDelete: string;
begin
  Result:='DELETE FROM ELE_BUDGET_GROUPID WHERE   CHR_ID=:CHR_ID';
end;

function TELEBUDGETGROUPID.GetStrInsert: string;
begin
  Result:='INSERT INTO ELE_BUDGET_GROUPID'
         +'    ( SET_YEAR, CHR_ID, CHR_CODE, DISP_CODE, CHR_NAME, LEVEL_NUM'
         +'    , IS_LEAF, ENABLED, CREATE_DATE, CREATE_USER, LATEST_OP_DATE'
         +'    , IS_DELETED, LATEST_OP_USER, LAST_VER, CHR_CODE1, CHR_CODE2'
         +'    , CHR_CODE3, CHR_CODE4, CHR_CODE5, RG_CODE, PARENT_ID'
         +'    , CHR_ID1, CHR_ID2, CHR_ID3, CHR_ID4, CHR_ID5)'
         +'    VALUES'
         +'    (:SET_YEAR,:CHR_ID,:CHR_CODE,:DISP_CODE,:CHR_NAME,:LEVEL_NUM'
         +'    ,:IS_LEAF,:ENABLED,:CREATE_DATE,:CREATE_USER,:LATEST_OP_DATE'
         +'    ,:IS_DELETED,:LATEST_OP_USER,:LAST_VER,:CHR_CODE1,:CHR_CODE2'
         +'    ,:CHR_CODE3,:CHR_CODE4,:CHR_CODE5,:RG_CODE,:PARENT_ID'
         +'    ,:CHR_ID1,:CHR_ID2,:CHR_ID3,:CHR_ID4,:CHR_ID5)';
end;

function TELEBUDGETGROUPID.GetStrsIndex: string;
begin
  Result:=Format('%S',[CHRID]);
end;

function TELEBUDGETGROUPID.GetStrUpdate: string;
begin
  Result:='UPDATE  ELE_BUDGET_GROUPID SET'
         +'    SET_YEAR=:SET_YEAR,'
         +'    CHR_CODE=:CHR_CODE,'
         +'    DISP_CODE=:DISP_CODE,'
         +'    CHR_NAME=:CHR_NAME,'
         +'    LEVEL_NUM=:LEVEL_NUM,'
         +'    IS_LEAF=:IS_LEAF,'
         +'    ENABLED=:ENABLED,'
         +'    CREATE_DATE=:CREATE_DATE,'
         +'    CREATE_USER=:CREATE_USER,'
         +'    LATEST_OP_DATE=:LATEST_OP_DATE,'
         +'    IS_DELETED=:IS_DELETED,'
         +'    LATEST_OP_USER=:LATEST_OP_USER,'
         +'    LAST_VER=:LAST_VER,'
         +'    CHR_CODE1=:CHR_CODE1,'
         +'    CHR_CODE2=:CHR_CODE2,'
         +'    CHR_CODE3=:CHR_CODE3,'
         +'    CHR_CODE4=:CHR_CODE4,'
         +'    CHR_CODE5=:CHR_CODE5,'
         +'    RG_CODE=:RG_CODE,'
         +'    PARENT_ID=:PARENT_ID,'
         +'    CHR_ID1=:CHR_ID1,'
         +'    CHR_ID2=:CHR_ID2,'
         +'    CHR_ID3=:CHR_ID3,'
         +'    CHR_ID4=:CHR_ID4,'
         +'    CHR_ID5=:CHR_ID5'
         +'    WHERE CHR_ID=:CHR_ID';
end;

constructor TELEBUDGETGROUPID.Create;
begin

end;

destructor TELEBUDGETGROUPID.Destroy;
begin

  inherited;
end;

class function TELEBUDGETGROUPID.ReadDS(AUniQuery: TUniQuery): TUniEngine;
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  Result:=TELEBUDGETGROUPID.Create;

  with TELEBUDGETGROUPID(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='SET_YEAR' then
      begin
        SETYEAR  :=Field.AsFloat;
      end else
      if FieldName='CHR_ID' then
      begin
        CHRID    :=Field.AsString;
      end else
      if FieldName='CHR_CODE' then
      begin
        CHRCODE  :=Field.AsString;
      end else
      if FieldName='DISP_CODE' then
      begin
        DISPCODE :=Field.AsString;
      end else
      if FieldName='CHR_NAME' then
      begin
        CHRNAME  :=Field.AsString;
      end else
      if FieldName='LEVEL_NUM' then
      begin
        LEVELNUM :=Field.AsFloat;
      end else
      if FieldName='IS_LEAF' then
      begin
        ISLEAF   :=Field.AsFloat;
      end else
      if FieldName='ENABLED' then
      begin
        ENABLED  :=Field.AsFloat;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='CREATE_USER' then
      begin
        CREATEUSER:=Field.AsString;
      end else
      if FieldName='LATEST_OP_DATE' then
      begin
        LATESTOPDATE:=Field.AsString;
      end else
      if FieldName='IS_DELETED' then
      begin
        ISDELETED:=Field.AsFloat;
      end else
      if FieldName='LATEST_OP_USER' then
      begin
        LATESTOPUSER:=Field.AsString;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end else
      if FieldName='CHR_CODE1' then
      begin
        CHRCODE1 :=Field.AsString;
      end else
      if FieldName='CHR_CODE2' then
      begin
        CHRCODE2 :=Field.AsString;
      end else
      if FieldName='CHR_CODE3' then
      begin
        CHRCODE3 :=Field.AsString;
      end else
      if FieldName='CHR_CODE4' then
      begin
        CHRCODE4 :=Field.AsString;
      end else
      if FieldName='CHR_CODE5' then
      begin
        CHRCODE5 :=Field.AsString;
      end else
      if FieldName='RG_CODE' then
      begin
        RGCODE   :=Field.AsString;
      end else
      if FieldName='PARENT_ID' then
      begin
        PARENTID :=Field.AsString;
      end else
      if FieldName='CHR_ID1' then
      begin
        CHRID1   :=Field.AsString;
      end else
      if FieldName='CHR_ID2' then
      begin
        CHRID2   :=Field.AsString;
      end else
      if FieldName='CHR_ID3' then
      begin
        CHRID3   :=Field.AsString;
      end else
      if FieldName='CHR_ID4' then
      begin
        CHRID4   :=Field.AsString;
      end else
      if FieldName='CHR_ID5' then
      begin
        CHRID5   :=Field.AsString;
      end;
    end
  end;  
end;

class procedure TELEBUDGETGROUPID.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  if Result=nil then Exit;

  with TELEBUDGETGROUPID(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='SET_YEAR' then
      begin
        SETYEAR  :=Field.AsFloat;
      end else
      if FieldName='CHR_ID' then
      begin
        CHRID    :=Field.AsString;
      end else
      if FieldName='CHR_CODE' then
      begin
        CHRCODE  :=Field.AsString;
      end else
      if FieldName='DISP_CODE' then
      begin
        DISPCODE :=Field.AsString;
      end else
      if FieldName='CHR_NAME' then
      begin
        CHRNAME  :=Field.AsString;
      end else
      if FieldName='LEVEL_NUM' then
      begin
        LEVELNUM :=Field.AsFloat;
      end else
      if FieldName='IS_LEAF' then
      begin
        ISLEAF   :=Field.AsFloat;
      end else
      if FieldName='ENABLED' then
      begin
        ENABLED  :=Field.AsFloat;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='CREATE_USER' then
      begin
        CREATEUSER:=Field.AsString;
      end else
      if FieldName='LATEST_OP_DATE' then
      begin
        LATESTOPDATE:=Field.AsString;
      end else
      if FieldName='IS_DELETED' then
      begin
        ISDELETED:=Field.AsFloat;
      end else
      if FieldName='LATEST_OP_USER' then
      begin
        LATESTOPUSER:=Field.AsString;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end else
      if FieldName='CHR_CODE1' then
      begin
        CHRCODE1 :=Field.AsString;
      end else
      if FieldName='CHR_CODE2' then
      begin
        CHRCODE2 :=Field.AsString;
      end else
      if FieldName='CHR_CODE3' then
      begin
        CHRCODE3 :=Field.AsString;
      end else
      if FieldName='CHR_CODE4' then
      begin
        CHRCODE4 :=Field.AsString;
      end else
      if FieldName='CHR_CODE5' then
      begin
        CHRCODE5 :=Field.AsString;
      end else
      if FieldName='RG_CODE' then
      begin
        RGCODE   :=Field.AsString;
      end else
      if FieldName='PARENT_ID' then
      begin
        PARENTID :=Field.AsString;
      end else
      if FieldName='CHR_ID1' then
      begin
        CHRID1   :=Field.AsString;
      end else
      if FieldName='CHR_ID2' then
      begin
        CHRID2   :=Field.AsString;
      end else
      if FieldName='CHR_ID3' then
      begin
        CHRID3   :=Field.AsString;
      end else
      if FieldName='CHR_ID4' then
      begin
        CHRID4   :=Field.AsString;
      end else
      if FieldName='CHR_ID5' then
      begin
        CHRID5   :=Field.AsString;
      end;
    end
  end;  
end;

class function  TELEBUDGETGROUPID.CopyIt(AELEBUDGETGROUPID: TELEBUDGETGROUPID): TELEBUDGETGROUPID;
begin
  Result:=TELEBUDGETGROUPID.Create;
  TELEBUDGETGROUPID.CopyIt(AELEBUDGETGROUPID,Result)
end;

class procedure TELEBUDGETGROUPID.CopyIt(AELEBUDGETGROUPID:TELEBUDGETGROUPID;var Result:TELEBUDGETGROUPID);
begin
  if Result=nil then Exit;
  Result.SETYEAR  :=AELEBUDGETGROUPID.SETYEAR;
  Result.CHRID    :=AELEBUDGETGROUPID.CHRID;
  Result.CHRCODE  :=AELEBUDGETGROUPID.CHRCODE;
  Result.DISPCODE :=AELEBUDGETGROUPID.DISPCODE;
  Result.CHRNAME  :=AELEBUDGETGROUPID.CHRNAME;
  Result.LEVELNUM :=AELEBUDGETGROUPID.LEVELNUM;
  Result.ISLEAF   :=AELEBUDGETGROUPID.ISLEAF;
  Result.ENABLED  :=AELEBUDGETGROUPID.ENABLED;
  Result.CREATEDATE:=AELEBUDGETGROUPID.CREATEDATE;
  Result.CREATEUSER:=AELEBUDGETGROUPID.CREATEUSER;
  Result.LATESTOPDATE:=AELEBUDGETGROUPID.LATESTOPDATE;
  Result.ISDELETED:=AELEBUDGETGROUPID.ISDELETED;
  Result.LATESTOPUSER:=AELEBUDGETGROUPID.LATESTOPUSER;
  Result.LASTVER  :=AELEBUDGETGROUPID.LASTVER;
  Result.CHRCODE1 :=AELEBUDGETGROUPID.CHRCODE1;
  Result.CHRCODE2 :=AELEBUDGETGROUPID.CHRCODE2;
  Result.CHRCODE3 :=AELEBUDGETGROUPID.CHRCODE3;
  Result.CHRCODE4 :=AELEBUDGETGROUPID.CHRCODE4;
  Result.CHRCODE5 :=AELEBUDGETGROUPID.CHRCODE5;
  Result.RGCODE   :=AELEBUDGETGROUPID.RGCODE;
  Result.PARENTID :=AELEBUDGETGROUPID.PARENTID;
  Result.CHRID1   :=AELEBUDGETGROUPID.CHRID1;
  Result.CHRID2   :=AELEBUDGETGROUPID.CHRID2;
  Result.CHRID3   :=AELEBUDGETGROUPID.CHRID3;
  Result.CHRID4   :=AELEBUDGETGROUPID.CHRID4;
  Result.CHRID5   :=AELEBUDGETGROUPID.CHRID5;
end;

end.

